# Create your views here.
from projectManager.models import *
from django.shortcuts import render_to_response
import datetime

def testMe(request):
	context = {}
	context['projectinfo'] = Project.objects.project_info(1)
	context['allUsers'] = User.objects.grab_all()
	return render_to_response('test.html',context)

def dasboard(request):
	context = {};
	currUser = request.session['user']
	userProjects = ProjectWorkers.objects.getUsersProjects(currUser.email)
	userProjects.append(User.objects.getManagedProjects(currUser.email))
	userTasks = Task.objects.getUserTasks(currUser.email)
	for currTask in userTasks:
		if currTask.due_date < datetime.datetime.now():
			currTask.isLate = false
		else:
			currTask.isLate = true
	
	context['userProjects'] = userProjects
	context['allTasks'] = userTasks
	context['user'] = currUser
	return render_to_response('dashboard.html',context)

# this view has no template!?
def editEmployee(request,empEmail): #needs a url to capture the employee email to edit
	employee = User.objects.getUserInfo(empEmail)[0]
	certs = Certifications.objects.getUserCerts(empEmail) # needs a manager to get all certfications for an employee
	context = {}
	
	return render_to_response('employee_info.html',context)
	
def login(request):
	currUser = User.objects.getUserInfo(request.session['email'])[0]
	
def manageEmps(request):
	context = {}
	context['allEmployees'] = User.objects.grab_all()
	return render_to_response('employee_management.html',context)
	
def empTaskReport(request):
	# TODO
	
def 